package com.yunyike.service.impl;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.yunyike.mapper.CityMapper;
import com.yunyike.model.City;
import com.yunyike.service.ICityService;

@Service("cityServiceImpl")
public class CityServiceImpl implements ICityService{

	private Logger log = LoggerFactory.getLogger(CityServiceImpl.class);

	@Autowired
	private CityMapper cityMapper;
	
	public int addCity(City city) {
		
		log.info("----->> add city....");
		
		int result = 0;
		try {
			result = cityMapper.insert(city);
		} catch (Exception e) {
			log.info("add city has errors,message:"+e.getMessage(),e);
		}
		
		log.info("add city end .result:"+result+"<<----");
		
		return result;
	}

	/**
	 *  
	 */
	public City findCityById(String cityId) {
		
		log.info("----->> find city....");
		
		City city = null;
		try {
			city = cityMapper.selectByPrimaryKey(cityId);
		} catch (Exception e) {
			log.info("find city has errors,message:"+e.getMessage(),e);
		}
		
		log.info("find city end .");
		
		return city;
	}

}
